local globalFunc = require("app.utils.globalFunc")
local M = {}

function M:updateScore(score)
	local recordPath = cc.FileUtils:getInstance():getWritablePath().."/record.lua"
	local needUpdate = true
	if cc.FileUtils:getInstance():isFileExist(recordPath) then
		local tab = dofile(recordPath)
		if tab.heightScore>score then
			needUpdate = false
		end
	end
	if needUpdate then
		local file = io.open(recordPath,"w")
		local record = {heightScore = score}
		local str = globalFunc.tableToStr(record,nil,"return ")
		if file then
			file:write(str)
			file:close()
		end
	end

end

function M:getHeightScore()
	local recordPath = cc.FileUtils:getInstance():getWritablePath().."/record.lua"
	if cc.FileUtils:getInstance():isFileExist(recordPath) then
		local tab = dofile(recordPath)
		return tab.heightScore
	end
	return 0
end

return M